package com.link.base.base.agreement.controller;

import com.link.base.base.agreement.model.AgrDetail;
import com.link.base.base.agreement.service.AgrDetailService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Copyright  hande Company. All Rights Reserved.
 *
 * @author unknwon
 * @date: 2018/11/8 10:33
 * @version 1.0
 */

@Controller
@RequestMapping("/link/agrDetail")
public class AgrDetailController extends BasicController<AgrDetail> {

    @Resource
    private AgrDetailService agrDetailService;

    @Override
    public BasicService<AgrDetail> getBasicService() throws Exception {
        return agrDetailService;
    }

    /**
     * 预处理：存在父子级联，所以强制父Id不能为空
     * @param entity
     * @param request
     * @throws Exception
     */
    @Override
    public void beforQueryExample(AgrDetail entity, HttpServletRequest request) throws Exception {
        if (null == entity.getId()) {
            entity.setAgrId(0L);
        } else {
            entity.setAgrId(entity.getId());
        }
        entity.setId(null);
    }
}
